package com.jjlin.chapter_8;
import java.util.Scanner;

public class CD37{

    public static void swap(int[] arr, int i, int j){
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    public static void sort(int[] arr, int l, int r){
        if(arr == null || arr.length < 2)
            return;
        int less = l - 1;
        int more = r + 1;
        int cur = l;
        while(cur < more){
            if(arr[cur] < 1)
                swap(arr, ++less, cur++);
            else if(arr[cur] > 1)
                swap(arr, --more, cur);
            else
                cur++;
        }
    }

    public static void printArray(int[] arr){
        int i;
        for(i = 0; i < arr.length - 1; i++)
            System.out.print(arr[i] + " ");
        System.out.println(arr[i]);
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] arr = new int[count];
        for(int i = 0; i < count; i++)
            arr[i] = sc.nextInt();
        sort(arr, 0, arr.length - 1);
        printArray(arr);
    }
}
